//package top.fangw.tenant.filter;
//
//import jakarta.servlet.FilterChain;
//import jakarta.servlet.ServletException;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestAttributes;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.springframework.web.filter.OncePerRequestFilter;
//import top.fangw.common.core.util.TenantIdUtil;
//
//import java.io.IOException;
//
///**
// * @description:
// * @author: fgw
// * @createDate: 2024/2/26
// */
//@Component
//public class RequestContextFilter extends OncePerRequestFilter {
//
//    // 省略类中其他代码...
//
//    // 该方法属于OncePerRequestFilter的模板方法，
//    // 会在OncePerRequestFilter#doFilter(ServletRequest, ServletResponse, FilterChain)中被调用
//    protected void doFilterInternal(
//            HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
//            throws ServletException, IOException {
//
//        // 创建RequestAttributes的子类对象`ServletRequestAttributes`
//        ServletRequestAttributes attributes = new ServletRequestAttributes(request, response);
//        RequestContextHolder.setRequestAttributes(attributes, true);
//
//        try {
//            filterChain.doFilter(request, response);
//        }
//        finally {
//            if (logger.isDebugEnabled()) {
//                logger.debug("Cleared thread-bound request context: " + request);
//            }
//            attributes.requestCompleted();
//        }
//    }
//
//
//
//
//}
